<?php
require_once 'Zend/Log/Formatter/Simple.php';
require_once 'Zend/Log/Filter/Priority.php';
require_once 'Zend/Log/Writer/Stream.php';
require_once 'Zend/Log.php';

class Rosemoore_Logger extends Zend_Log{

    public function __construct()
    {
    // set formatter, add %class% to save class name
            $format = '%timestamp% (%priorityName%) %priority% %class%: %message%'. PHP_EOL;
            $this->_formatter = new Zend_Log_Formatter_Simple($format);
            parent::addWriter($this->_errorWriter());
            parent::addWriter($this->_allWriter());
            parent::__construct();
    }

    /**
    * Writer for error log message
    * Error log message will write to file error.log
    */
    protected function _errorWriter()
    {
        $writer = new Zend_Log_Writer_Stream('../logs/error.log');
        $writer->addFilter(new Zend_Log_Filter_Priority(Zend_Log::ERR));
        $writer->setFormatter($this->_formatter);
        return $writer;
    }

/**
    * Writer for another log message
    * Another log message will write to file system.log
    */
    protected function _allWriter()
    {
        $writer = new Zend_Log_Writer_Stream('../logs/system.log');
        $writer->addFilter(new Zend_Log_Filter_Priority(Zend_Log::INFO));
        $writer->setFormatter($this->_formatter);
        return $writer;
    }
}

